package com.dtsheep.rxjava.stduy.observable;

import com.dtsheep.rxjava.entity.Student;
import rx.Observable;
import rx.Scheduler;
import rx.schedulers.Schedulers;

import java.util.HashMap;
import java.util.Map;

/**
 * CombinDemo
 *
 * <p>
 *     合并测试
 * </p>
 *
 * @author chuanbai
 * @date 2024/9/14
 */
public class MergeDemo {

    public static void main(String[] args) {
        Map<String, Student> map1 = new HashMap<>();
        map1.put("user", new Student(10, "张三"));
        Observable<Map<String, Student>> observable1 = Observable.just(map1);

        Map<String, Student> map2 = new HashMap<>();
        map2.put("user", new Student(10, "李四"));
        Observable<Map<String, Student>> observable2 = Observable.just(map2);

        observable1 = observable1.mergeWith(observable2);
        Observable<Map<String, Student>> mapObservable = observable1.subscribeOn(Schedulers.computation());
        System.out.println(mapObservable.toBlocking().first());

    }
}
